package com.demo.explore.handler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

/**
 * 授权成功处理器
 *
 * @author Logan
 * @createDate 2019-02-07
 *
 */
@Component
public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {

    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {

        // 设置默认跳转页面，当没有重定向页面时（例如：直接访问登录页面），此配置生效
        super.setDefaultTargetUrl("/main.html");
        super.onAuthenticationSuccess(request, response, authentication);
    }

}